<template>
	<view style="padding: 0 50rpx;">
		<view
			style="padding: 60rpx 0;padding-top: 130rpx; display: flex;flex-direction: row;justify-content: center;align-items: center;border-bottom: 2rpx solid #707070;">
			<view style="" @click="selimg">
				<u--image :showLoading="true" :src="state.$userInfo.Item.Avatar" width="130rpx" height="130rpx">
				</u--image>
			</view>
			<view style="flex: 1;flex-direction: column;display: flex;margin-left: 36rpx;">
				<text style="font-size: 36rpx;color: #2A3954;">{{state.$userInfo.Item.Email}}</text>
				<text style="font-size: 24rpx;color: #2A3954;padding-top: 24rpx;">Available</text>
			</view>
			<view class="">
				<u--image :showLoading="true" src="/static/erweima.png" width="48rpx" height="48rpx"></u--image>
			</view>
		</view>
		<view class="">
			<view @click="linto('/pages/Settings/account')"
				style="display: flex;flex-direction: row;align-items: center;justify-content: center;padding: 40rpx 0;">
				<view style="width: 65rpx;display: flex;justify-content: center;">
					<u--image :showLoading="true" src="/static/yaosi.png" width="24rpx" height="46rpx"></u--image>
				</view>
				<view class="" style="flex: 1;flex-direction: column;display: flex;margin-left: 50rpx;">
					<text style="font-size: 30rpx;color: #2A3954;">Account</text>
					<text style="font-size: 24rpx;color: #2A3954;">Privacy, security, change number</text>
				</view>
			</view>
			<view @click="linto('/pages/Settings/notifi')"
				style="display: flex;flex-direction: row;align-items: center;justify-content: center;padding: 40rpx 0;">
				<view style="width: 65rpx;display: flex;justify-content: center;">
					<u--image :showLoading="true" src="/static/naoling.png" width="36rpx" height="44rpx"></u--image>
				</view>
				<view class="" style="flex: 1;flex-direction: column;display: flex;margin-left: 50rpx;">
					<text style="font-size: 30rpx;color: #2A3954;">Notifications</text>
					<text style="font-size: 24rpx;color: #2A3954;">Message, group & call tones</text>
				</view>
			</view>
			<view @click="linto('/pages/Settings/storage')"
				style="display: flex;flex-direction: row;align-items: center;justify-content: center;padding: 40rpx 0;">
				<view style="width: 65rpx;display: flex;justify-content: center;">
					<u--image :showLoading="true" src="/static/topjian.png" width="36rpx" height="36rpx"></u--image>
				</view>
				<view class="" style="flex: 1;flex-direction: column;display: flex;margin-left: 50rpx;">
					<text style="font-size: 30rpx;color: #2A3954;">Storage and data</text>
					<text style="font-size: 24rpx;color: #2A3954;">Network usage , auto-download</text>
				</view>
			</view>
			<view @click="linto('/pages/Settings/help')"
				style="display: flex;flex-direction: row;align-items: center;justify-content: center;padding: 40rpx 0;">
				<view style="width: 65rpx;display: flex;justify-content: center;">
					<u--image :showLoading="true" src="/static/weihao.png" width="30rpx" height="34rpx"></u--image>
				</view>
				<view class="" style="flex: 1;flex-direction: column;display: flex;margin-left: 50rpx;">
					<text style="font-size: 30rpx;color: #2A3954;">Help</text>
					<text style="font-size: 24rpx;color: #2A3954;">Help center, contact us, privacy policy</text>
				</view>
			</view>
			<view @click="linto('/pages/Settings/about')"
				style="display: flex;flex-direction: row;align-items: center;justify-content: center;padding: 40rpx 0;">
				<view style="width: 65rpx;display: flex;justify-content: center;">
					<u--image :showLoading="true" src="/static/tanhao.svg" width="50rpx" height="50rpx"></u--image>
				</view>
				<view class="" style="flex: 1;flex-direction: column;display: flex;margin-left: 50rpx;">
					<text style="font-size: 30rpx;color: #2A3954;">About Us</text>
				</view>
			</view>
			<view @click="$u.route('/pages/login/login')"
				style="display: flex;flex-direction: row;align-items: center;justify-content: center;padding: 40rpx 0;">
				<view style="width: 65rpx;display: flex;justify-content: center;">
					<u--image :showLoading="true" src="/static/tanhao.svg" width="50rpx" height="50rpx"></u--image>
				</view>
				<view class="" style="flex: 1;flex-direction: column;display: flex;margin-left: 50rpx;">
					<text style="font-size: 30rpx;color: #2A3954;">Login</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		pathToBase64,
		base64ToPath
	} from '@/sdk/mmmm-image-tools/index.js'
	export default {
		data() {
			return {
				state: {}
			};
		},
		onLoad() {
			console.log(this.$store.state)
			this.state = this.$store.state;
		},
		methods: {
			linto(url) {
				uni.$u.route({
					url
				})
			},
			selimg() {
				uni.chooseImage({
					count: 1, //默认9
					// sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					// sourceType: ['album'], //从相册选择
					success: (res) => {
						var file = res.tempFiles[0];
						var base64 = pathToBase64(file.path).then((res) => {
							this.setdata({
								avatar: res,
							}, file.path, 0);
						})
					}
				});
			},
			setdata(query) {
				this.$store.commit('postdata', {
					url: '/api/Manager/UploadPhoto',
					data: {
						"UserID": this.$store.state.$userInfo.Item.UserID,
						"FirstName": "Tangrixin",
						"LastName": "Tangrixin222",
						"Phone": "13688888",
						"Gender": true,
						"Birthday": "2022-06-13T07:37:56.102Z",
						"Language": "",
						"Avatar": query.avatar,
						"TimeOffset": 8,
						"AppID": "119"
					},
					success: (res) => {
						console.log(res)
						
						if (res.Message) {
							uni.$u.toast(res.Message);
						}
						if (res.State === 0 || res.State === 100) {
							// this.list = res.Items;
							return
						}
					},
					error(res) {
						console.log(res)
						uni.$u.toast('server error');
					}
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
